<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Document</title>
    <style>
        #ad{
            width: 100%;
            height: 300px;
            background: rgb(180, 122, 180);
        }
    </style>
</head>
<body>
    <div id="ad"></div>

    <script>
        let ad = document.querySelector('#ad');

        //绑定单击事件
        ad.addEventListener('click', function(){
            console.log('点击了');
            this.clickTime = Date.now();
            //相减
            let result = this.clickTime - this.touchTime;
            //输出间隔
            console.log('触摸与点击之间的时间间隔: '+result);
        });

        //绑定触摸事件
        ad.addEventListener('touchstart', function(e){
            console.log('触摸了');
            this.touchTime = Date.now();
            //阻止默认行为
            e.preventDefault();
        })

    </script>
</body>
</html>